import { Cell } from "pack-antv-x6"
import {get} from "lodash-es"
import Main from "../main"

import useLoop from "./loop"

export default (main:Main) => {
    //


    // 设置数据并依据节点类型设置 prop
    const setData = (cell:Cell,d:any) => {
        const name = cell.prop('name')
        const data = cell.getData();
        Object.assign(data,d);
        //
        
    }
    // 获取节点数据
    const getData = (cell:Cell,key?:string|string[]) => {
        const data = cell.getData();
        return key ? get(data,key) : data;
    }

    const Loop = useLoop(main)

    return {
        setData,
        getData,

        // modules
        Loop,
    }
}